package cn.wolfcode.util;


import cn.wolfcode.exception.logicException;
import lombok.Getter;
import lombok.Setter;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;

@Setter
@Getter
public class Lead {
   public static String username;
   public static String Name;
   public static int age;
   public static String email;
   public static String deptName;

   public static void examine(Sheet sheet , int index){
      //获取当前行
      Row row = sheet.getRow(index);
      String UsernameStr= row.getCell(0).getStringCellValue();
      String NameStr= row.getCell(1).getStringCellValue();
      int AgeNum= (int)row.getCell(2).getNumericCellValue();
      String EmailStr= row.getCell(3).getStringCellValue();
      String deptNameStr = row.getCell(4).getStringCellValue();

      if ( UsernameStr == null || UsernameStr == "") {
         throw new logicException("第"+(index+1)+"行,用户名有异常");
      }else {
         username = UsernameStr;
      }
      if ( NameStr == null || NameStr == "") {
         throw new logicException("第"+(index+1)+"行,名字有异常");
      }else{
         Name=NameStr;
      }
      if ( AgeNum == 0 ) {
         throw new logicException("第" +(index+1) + "行,年龄有异常");
      }else {
         age=AgeNum;
      }
      if ( EmailStr == null || EmailStr == "") {
         throw new logicException("第"+(index+1)+"行,邮箱有异常");
      }else {
         email=EmailStr;
      }
      if ( deptNameStr == null || deptNameStr == "") {
         throw new logicException("第"+(index+1)+"行,部门有异常");
      }else {
         deptName =deptNameStr;
      }

   }
}
